<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="demiBoard.DemiBoardFunction" %>

<%if(true/*Integer.parseInt((String)session.getAttribute("userGrade"))>900*/){%>

<%ArrayList boardAdminList=(ArrayList)request.getAttribute("boardAdminList"); %>
<div id ="demiBoardAdmin">
	<div id="demiBoardModify">
		<div id="nameLabel">게시판id</div><input type="text" class="cBoardId" />
		<div id="nameLabel">게시판이름</div><input type="text"  class="cBoardName"/>
		<div id="nameLabel">보여줄 포스팅 겟수</div><input type="text" class="cBoardPostNumber" />
		<div id="nameLabel">한페이지에 나올페이지겟수</div><input type="text"  class="cBoardPageNumber"/>
	</div>
	<div>
		<input type="button" value ="추가" onclick="demiBoardAdd();"/>
		<input type="button" value ="삭제" onclick="demiBoardDelete();"/>
		<input type="button" value ="수정" onclick="demiBoardModify();"/>
	</div>	
	<div id="demiBoardAdminList">
		<dh><span>boardId</span><span>boardName</span><span>포스팅 겟수</span><span>페이지겟수</span></dh>
		<%=DemiBoardFunction.getBoardMenuStatusTag(boardAdminList)%>
	</div>
	
	<form id ="demiAdminPaper">
		<input type="hidden"  name="reqFunc" class ="reqFunc" value=""/>
		<input type="hidden"  name="cBoardId" class ="cBoardId" value=""/>
		<input type="hidden"  name="cBoardName" class="cBoardName" value=""/>
		<input type="hidden"  name="cBoardPostNumber" class ="cBoardPostNumber" value=""/>
		<input type="hidden"  name="cBoardPageNumber" class="cBoardPageNumber" value=""/>
	</form>
</div>
<script type="text/javascript">
	function demiBoardAdd(){
		var cBoardId=jQuery("#demiBoardModify .cBoardName").attr("value");
		
		if(demiBoardValidate()=="false"){alert("미입력");return 0;}
		copyForm();
		jQuery("#demiBoardAdmin .reqFunc").attr("value","boardAdd");
		ajaxSend('/boardPage',aMainBodyRight,'post','demiAdminPaper','mainBodyRight');
	}
	function demiBoardDelete(){
		var cBoardId=jQuery("#demiBoardModify .cBoardId").attr("value");
		if(cBoardId==""){alert("미선택");return 0;}
		copyForm();
		jQuery("#demiBoardAdmin .reqFunc").attr("value","boardDelete");
		ajaxSend('/boardPage',aMainBodyRight,'post','demiAdminPaper','mainBodyRight');
	}
	function demiBoardModify(){
		var cBoardId=jQuery("#demiBoardModify .cBoardId").attr("value");
		if(cBoardId==""){alert("미선택");return 0;}
		if(demiBoardValidate()=="false"){alert("미입력");return 0;}
		copyForm();
		jQuery("#demiBoardAdmin .reqFunc").attr("value","boardModify");
		ajaxSend('/boardPage',aMainBodyRight,'post','demiAdminPaper','mainBodyRight');
	}
	function copyForm(){
		var demiBoardModify=jQuery("#demiBoardModify");
		var demiAdminPaper=jQuery("#demiAdminPaper");
		demiAdminPaper.children(".cBoardId").attr("value",demiBoardModify.children(".cBoardId").attr("value"));
		demiAdminPaper.children(".cBoardName").attr("value",demiBoardModify.children(".cBoardName").attr("value"));
		demiAdminPaper.children(".cBoardPostNumber").attr("value",demiBoardModify.children(".cBoardPostNumber").attr("value"));
		demiAdminPaper.children(".cBoardPageNumber").attr("value",demiBoardModify.children(".cBoardPageNumber").attr("value"));
	}
	function demiBoardValidate(){
		var demiBoardModify=jQuery("#demiBoardModify");
		var cBoardName=demiBoardModify.children(".cBoardName").attr("value");
		var cBoardPostNumber=demiBoardModify.children(".cBoardPostNumber").attr("value");
		var cBoardPageNumber=demiBoardModify.children(".cBoardPageNumber").attr("value");
		if(cBoardName!="" && cBoardPostNumber!="" && cBoardPageNumber!=""){
			return "true";	
		}
		else{
			return "false";
		}
	}


</script>
<%}else{%>
	<script type="text/javascript">
	alert("관리자 전용 게시판");
	</script>
<%} %>
